package com.dingxin.ship_together_api.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.util.SaResult;
import com.dingxin.ship_together_api.entity.MessageInfo;
import com.dingxin.ship_together_api.entity.constant.PermissionConstant;
import com.dingxin.ship_together_api.entity.vo.PageQueryVo;
import com.dingxin.ship_together_api.service.MessageInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Author: ctj
 * Date: 2023-01-12
 * Time: 9:45
 */
@RestController
@SaCheckLogin
@RequestMapping("message")
public class MessageController {

    @Autowired
    private MessageInfoService messageInfoService;

    @RequestMapping("add")
    @SaCheckPermission(PermissionConstant.System_MsgMng_Add)
    public SaResult add(@RequestBody MessageInfo messageInfo){
        return SaResult.ok().setData(messageInfoService.save(messageInfo));
    }

    @RequestMapping("list")
    @SaCheckPermission(PermissionConstant.System_MsgMng_Qry)
    public SaResult list(@RequestBody PageQueryVo pageQueryVo){
        return SaResult.ok().setData(messageInfoService.selectPage(pageQueryVo));
    }

}
